#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    
    int merge_sort(vector<int>&nums,int left,int right)
    {
        vector<int>tmp;
        if(left>=right)return 0;
        int mid=left+right>>1;
        int ans=merge_sort(nums,left,mid)+merge_sort(nums,mid+1,right);
        int i=left,j=mid+1,k=0;
        while(i<=mid&&j<=right)
        {
            if(nums[i]<=nums[j])tmp.push_back(nums[i++]);
            else{
                tmp.push_back(nums[j++]);
                ans=mid-i+1;
            }
        }
        while(i<=mid)tmp.push_back(nums[i++]);
        while(j<=right)tmp.push_back(nums[j++]);
        for(i=left,j=0;i<=right;i++,j++)nums[i]=tmp[j];
        return ans;

    }
    int reversePairs(vector<int>& nums) {
        return merge_sort(nums,0,nums.size()-1);
    }
};
int main()
{
    Solution s1;
    s1.reversePairs()
}